//
//  UITextView+fontSize.m
//  Pods-ToolUtil_Example
//
//  Created by 露露 on 2017/10/10.
//

#import "UITextView+fontSize.h"
#import <YYKit/YYKit.h>
#import <objc/runtime.h>

// 屏幕适配，获取缩放后的值
#define ks(v) (kScreenWidth/375.0 * v)

@implementation UITextView (fontSize)
+ (void)load {
    [super load];
    Method imp = class_getInstanceMethod([self class], @selector(initWithCoder:));
    Method myImp = class_getInstanceMethod([self class], @selector(myInitWithCoder:));
    method_exchangeImplementations(imp, myImp);
}

- (id)myInitWithCoder:(NSCoder*)aDecode {
    [self myInitWithCoder:aDecode];
    if (self) {
        if (kScreenWidth != 375) {
            self.font = [self.font fontWithSize:ks(self.font.pointSize)];
        }
    }
    return self;
}

@end
